package com.casic.ops.utils.pipeline;

import com.casic.ops.entity.domain.pipeline.PipelineDO;
import com.casic.ops.entity.domain.pipeline.PipelineLoggerDO;
import com.casic.ops.entity.dto.pipeline.PipelineDTO;
import com.casic.ops.entity.dto.pipeline.PipelineLoggerDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 流水线执行记录转换类
 * @author cww
 * @date 2022/6/17
 */
@Component
public class PipelineLoggerConvertor {

    public PipelineLoggerDO toDO(PipelineLoggerDTO pipelineLoggerDTO){
        PipelineLoggerDO pipelineLoggerDO=new PipelineLoggerDO();
        pipelineLoggerDO.setPipelineUuid(pipelineLoggerDTO.getPipelineUuid());
        pipelineLoggerDO.setCreator(pipelineLoggerDTO.getCreator());
        pipelineLoggerDO.setModifier(pipelineLoggerDTO.getModifier());
        pipelineLoggerDO.setExecuteStartTime(pipelineLoggerDTO.getExecuteStartTime());
        pipelineLoggerDO.setDeleted(pipelineLoggerDTO.getDeleted());
        pipelineLoggerDO.setContent(pipelineLoggerDTO.getContent());
        pipelineLoggerDO.setFinalStatus(pipelineLoggerDTO.getFinalStatus());
        pipelineLoggerDO.setGmtModified(pipelineLoggerDTO.getGmtModified());
        pipelineLoggerDO.setGmtCreate(pipelineLoggerDTO.getGmtCreate());
        pipelineLoggerDO.setGraphContent(pipelineLoggerDTO.getGraphContent());
        pipelineLoggerDO.setId(pipelineLoggerDTO.getId());
        pipelineLoggerDO.setExecuteEndTime(pipelineLoggerDTO.getExecuteEndTime());
        pipelineLoggerDO.setUuid(pipelineLoggerDTO.getUuid());
        pipelineLoggerDO.setTriggerWay(pipelineLoggerDTO.getTriggerWay());
        return pipelineLoggerDO;
    }

    public PipelineLoggerDTO toDTO(PipelineLoggerDO pipelineLoggerDO){
        PipelineLoggerDTO pipelineLoggerDTO=new PipelineLoggerDTO();
        pipelineLoggerDTO.setPipelineUuid(pipelineLoggerDO.getPipelineUuid());
        pipelineLoggerDTO.setCreator(pipelineLoggerDO.getCreator());
        pipelineLoggerDTO.setModifier(pipelineLoggerDO.getModifier());
        pipelineLoggerDTO.setExecuteEndTime(pipelineLoggerDO.getExecuteEndTime());
        pipelineLoggerDTO.setDeleted(pipelineLoggerDO.getDeleted());
        pipelineLoggerDTO.setContent(pipelineLoggerDO.getContent());
        pipelineLoggerDTO.setFinalStatus(pipelineLoggerDO.getFinalStatus());
        pipelineLoggerDTO.setGmtModified(pipelineLoggerDO.getGmtModified());
        pipelineLoggerDTO.setGmtCreate(pipelineLoggerDO.getGmtCreate());
        pipelineLoggerDTO.setGraphContent(pipelineLoggerDO.getGraphContent());
        pipelineLoggerDTO.setId(pipelineLoggerDO.getId());
        pipelineLoggerDTO.setExecuteStartTime(pipelineLoggerDO.getExecuteStartTime());
        pipelineLoggerDTO.setUuid(pipelineLoggerDO.getUuid());
        pipelineLoggerDTO.setTriggerWay(pipelineLoggerDO.getTriggerWay());
        return pipelineLoggerDTO;

    }

    public List<PipelineLoggerDTO> toDTOList(List<PipelineLoggerDO> list){
        List<PipelineLoggerDTO> pipelineLoggerDTOList=new ArrayList<>();
        for(PipelineLoggerDO pipelineLoggerDo:list){
            pipelineLoggerDTOList.add(toDTO(pipelineLoggerDo));
        }
        return pipelineLoggerDTOList;
    }

    public List<PipelineLoggerDO> toDOList(List<PipelineLoggerDTO> list){
        List<PipelineLoggerDO> pipelineLoggerDOList=new ArrayList<>();
        for(PipelineLoggerDTO pipelineLoggerDTO:list){
            pipelineLoggerDOList.add(toDO(pipelineLoggerDTO));
        }
        return pipelineLoggerDOList;
    }


}
